package com.chenken;

import java.util.Set;

import com.chenken.graph.Graph;
import com.chenken.graph.Graph.EdgeInfo;
import com.chenken.graph.Graph.VertexVisitor;
import com.chenken.graph.Graph.WeightManager;
import com.chenken.graph.ListGraph;

public class Main {

	static WeightManager<Integer> weightManager = new WeightManager<Integer>() {
		@Override
		public int compare(Integer w1, Integer w2) {
			return w1 - w2;
		}
		@Override
		public Integer add(Integer w1, Integer w2) {
			return w1 + w2;
		}
	};
	
	public static void main(String[] args) {
		Graph<String,Integer> listGraph = new ListGraph<String,Integer>(weightManager);
		listGraph.addEdge("V1", "V0", 9);
		listGraph.addEdge("V1", "V2", 3);
		listGraph.addEdge("V2", "V0", 2);
		listGraph.addEdge("V2", "V3", 5);
		listGraph.addEdge("V3", "V4", 1);
		listGraph.addEdge("V0", "V4", 6);
		
		//listGraph.removeVertex("V0");
		//listGraph.print();
//		listGraph.bfs("V1", new VertexVisitor<String>() {
//			@Override
//			public boolean visit(String v) {
//				System.out.println(v);
//				return false;
//			}
//		});
//		System.out.println("-------------------------------");
//		listGraph.dfs("V1", new VertexVisitor<String>() {
//			@Override
//			public boolean visit(String v) {
//				System.out.println(v);
//				return false;
//			}
//		});
		
		Set<EdgeInfo<String, Integer>> edgeInfos = listGraph.mst();
		for(EdgeInfo<String, Integer> edgeInfo:edgeInfos) {
			System.out.println(edgeInfo);
		}
	}
	
}
